package com.freemarker.main;

import com.freemarker.pickdata.DataUtil;
import com.freemarker.pickdata.MyFreeMarker;
import com.freemarker.vo.TableEntity;

public class Main {

	public static void main(String[] args) throws Exception {
		System.out.println("------------- start ---------------------");
		// prepare("yibao_bind_card","demo2");
		// prepare("bee_order","wlctt-test2");
		prepare("reapal_daifu_query_batchpayquery","reapal");
		System.out.println("------------- end ---------");
	}

	public static void prepare(String tableName,String entityPackage) throws Exception {

		TableEntity tableEntity = DataUtil.pickPOData(tableName,entityPackage);

		MyFreeMarker.build(tableEntity, tableEntity.getClassName() + ".java", "po.ftl");

		MyFreeMarker.build(tableEntity, tableEntity.getClassName() + "Mapper.xml","mybatisMap.ftl");

		// Dao
		MyFreeMarker.build(tableEntity, tableEntity.getClassName() + "Dao.java", "Dao.ftl");

		MyFreeMarker.build(tableEntity, tableEntity.getClassName() + "Page.java", "poPage.ftl");
		// Service
		MyFreeMarker.build(tableEntity, tableEntity.getClassName() + "Service.java", "Service.ftl");

		// Control
		MyFreeMarker.build(tableEntity, tableEntity.getClassName() + "Controller.java","control.ftl");
		
		// JSP
		MyFreeMarker.build(tableEntity, tableEntity.getClassname() + ".jsp","jspTemplate.ftl");
		
		// javascript
		MyFreeMarker.build(tableEntity, "page-"+tableEntity.getClassname() + ".js","jsTemplate.ftl");

	}

}
